<!--头部公共部分-->
{include file="common/header" /}
<div class="x-nav">
    <a class="layui-btn layui-btn-xs layui-btn-small" style="float:right;margin-top: 10px;"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh"></i> </a>
</div>
<div id="dm_arrang" class="x-body" class="clear:both;">
    <div class="layui-row"
         style="padding-left:20px;border-left:1px solid #e5e5e5;border-right:1px solid #e5e5e5;">
        <!--        <div class="layui-form layui-col-md12 x-so layui-form-pane">-->
        <!--            <div class="layui-input-inline">-->
        <!--                <button class="layui-btn" id="search">-->
        <!--                    <i class="layui-icon layui-icon-search"></i>筛选</button>-->
        <!--                <button class="layui-btn layui-btn-danger" id="clear">-->
        <!--                    <i class="layui-icon"></i>重置</button>-->
        <!--                &lt;!&ndash;-->
        <!--                <button class="layui-btn" id="table-add">-->
        <!--                    <i class="layui-icon layui-icon-add-circle-fine"></i>新增排课</button>-->
        <!--                    &ndash;&gt;-->
        <!--            </div>-->
        <!--        </div>-->
    </div>
    <table class="layui-table" id="datalist" lay-filter="Event"></table>
    <script type="text/html" id="barTable">
        <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="detail">查看详情</a>
    </script>
<!--    <script type="text/html" id="audio">-->
<!--        {{#  if(d.is_comment == 1){ }}-->
<!--        <a href="{{ d.audio }}" target="_blank" class="layui-table-link">-->
<!--            <i class="layui-icon {{ d.audio_text }}" style="height: 40px;"></i>-->
<!--        </a>-->
<!--        {{#  } else { }}-->
<!--        <div class="layui-table-link">-->
<!--            <i class="layui-icon {{ d.audio_text }}" style="height: 40px;"></i>-->
<!--        </div>-->
<!--        {{#  } }}-->
<!--    </script>-->
<!--    <script type="text/html" id="video">-->
<!--        {{#  if(d.is_comment == 1){ }}-->
<!--        <a href="{{ d.video }}" target="_blank" class="layui-table-link">-->
<!--            <i class="layui-icon {{ d.video_text }}" style="height: 40px;"></i>-->
<!--        </a>-->
<!--        {{#  } else { }}-->
<!--        <div class="layui-table-link">-->
<!--            <i class="layui-icon {{ d.video_text }}" style="height: 40px;"></i>-->
<!--        </div>-->
<!--        {{#  } }}-->
<!--    </script>-->
<!--    <script type="text/html" id="picture">-->
<!--        {{#  if(d.is_comment == 1){ }}-->
<!--        <a href="{{ d.picture }}" target="_blank" class="layui-table-link">-->
<!--            <i class="layui-icon {{ d.picture_text }}" style="height: 40px;"></i>-->
<!--        </a>-->
<!--        {{#  } else { }}-->
<!--        <div class="layui-table-link">-->
<!--            <i class="layui-icon {{ d.picture_text }}" style="height: 40px;"></i>-->
<!--        </div>-->
<!--        {{#  } }}-->
<!--    </script>-->
</div>
<!--底部公共部分-->
{include file="common/footer" /}
<script>
    layui.use(['table', 'form','element', 'laydate', 'layer'], function () {
        var table = layui.table,
                laydate = layui.laydate,
                form = layui.form,
                element = layui.element,
                layer = layui.layer,
                $ = layui.$;

        var loading = layer.load();
        form.render(null, 'form-organization');
        form.on('submit(form-organization-search)', function (data) {
            let searchLoading = layer.load();
            table.reload('table-organization', {
                url: "{:url('Arranging/look_comment')}"
                , where: data.field
                , done: function () {
                    layer.close(searchLoading);
                }
            });
            return false;
        });
        var id = '{$cmdl_id}';
        //方法级渲染
        var tableIns = table.render({
            elem: '#datalist'
            , url: '{:url("Arranging/look_comment")}'
            , where: {'id':id}
            , method: 'POST'
            , loading: true
            , parseData: function (res) { //res 即为原始返回的数据
                if (res.code === 1) {
                    res.code = 0;
                } else {
                    res.code = -1;
                }
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.data //解析数据列表
                };
            },
            cols: [[
                {field: 'student_name', style:'color:#01AAED;font-weight: bold;',title: '学员名称', minWidth: 100, align: 'center'
                }, {field: 'time', title: '点评时间', minWidth: 100, align: 'center'
                }, {field: 'student_scoring', title: '点评分数', minWidth: 100, align: 'center'
                }, {field: 'publisher', title: '点评人', minWidth: 100, align: 'center'
                }, {field: 'content', title: '具体内容', minWidth: 100, align: 'center'
                // }, {field: 'audio', title: '音频', minWidth: 100, align: 'center',templet: '#audio'
                // }, {field: 'video', title: '视频', minWidth: 100, align: 'center',templet: '#video'
                // }, {field: 'picture', title: '图片', minWidth: 100, align: 'center',templet: '#picture'}
                }, {fixed: 'right', title: '操作', width: 100, align: 'center', toolbar: '#barTable'}
            ]]
            , height: 'full-180'
            , page: true
            , done: function () {
                layer.close(loading);
            }
        });

        //监听工具条
        table.on('tool(Event)', function (obj) {
            var data = obj.data; //获得当前行数据
            console.log(data)
            var layEvent = obj.event; //获得 lay-event 对应的值
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            if(layEvent === 'detail') { //查看
                location.href = "{:url('Arranging/look_comment_detail')}?cmdl_id="+data.class_manage_details_id+"&student_id="+data.student_id;
            }
        });

        //搜索项
        $('#search').click(function () {
            var field = {};
            field.class_grades_name = $('select[name=class_grades_name]').val();
            field.course_id = $('select[name=course_id]').val();
            field.campus_id = $('select[name=campus_id] option:selected').val();

            var create_date_rang = $('input[name=class_date]').val();
            if(create_date_rang.length > 0){
                strs_date=create_date_rang.split("-"); //字符分割
                field.start_date = strs_date[0]+'-'+strs_date[1]+'-'+strs_date[2];
                field.end_date = strs_date[3]+'-'+strs_date[4]+'-'+strs_date[5];
            }

            console.log(field);
            tableIns.reload({
                where: field,
                method: 'POST',
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });
        //清除
        $('#clear').click(function () {
            $('.layui-form-pane').find('.layui-input-inline').each(function (index, element) {
                $(element).find('input[type=text]').val('');
                $(element).find('select').val('');
            })
            tableIns.reload({
                where: {
                    'class_grades_name': '',
                    'course_id': '',
                    'campus_id':'',
                    'class_date':'',
                },
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });
    });
</script>

